package jm.coll.set;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * @Description HashSet测试
 * @date 2022/4/2 13:08
 */
public class HashSetTest {
    public static void main(String[] args) {
        HashSet<Integer> set = new HashSet<>();
        set.add(1);
        set.add(2);
        set.add(3);
        set.add(4);
        set.add(null);
        System.out.println(set.size() + ",-----==19col==-----");
        set.add(null);
        System.out.println(set.size() + ",-----==21col==-----");
        System.out.println(set);
        for (Integer integer : set) {
            System.out.println(integer);
        }

        Iterator<Integer> iterator = set.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }

    }

}
